<!--suppress ALL -->
<template>
    <div class="card rdsp-card-view" data-page="hiddenCheck">
        <div class="card-content rank-content card-content-padding hiddenCheck-container">
            <div class="rdsp-card-title">
                <div class="left-title">隐患整改</div>
                <div class="rdsp-card-title-right">
                  <div id="right-con" class="right-con">待整改总数<span id="stayCahngeNum">0</span></div>
                </div>
            </div>
            <div class="rdsp-card-con">
                <div class="hiddenCheck-top">
                  <div id="hiddenCheck-swiper" class="swiper-container">
                    <div class="swiper-pagination" id="hiddenCheck_pagination"></div>
                    <div class="swiper-wrapper" id="hiddenCheck_swiper"></div>
                  </div>
                </div>
                <div id="hiddenCheck-bottom" class="hiddenCheck-bottom">
                    <div class="hiddenCheck-hr">
                      <p id="hidden_delDate"><span class="iconfont icon-shandian" ></span><span id="speed_span">隐患处理速度：<span id="hidden_speed">0</span>天</span></p>
                      <p id="hidden_noDelDate" style="display: none"><span class="iconfont icon-shandian" ></span>最近无已处理完成的隐患</p>
                    </div>
                    <div class="hiddenCheck-text">
                      <div id="hit_div">击败了<span id="hit_num">0</span>的单位</div>
                      <span class="hiddenCheck-status-text hidden-statu-3" id="hit_num_text">请继续保持</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    return {
        data: function () {
            return {
            }
        },
        methods: {
            transStaus:function(status){
               var self = this;
              var $ = self.$$;
              if(status==1){
                return "整改中"
              }else if (status==2) {
                return "已完成" 
              }else if (status==5) {
                return "待指派" 
              }else {
                return "核实中" 
              }
            },
            getHiddenSwaper:function(){
                var self = this;
                var $ = self.$$;
                $("#hiddenCheck_swiper").empty();
                Dao.getHidDangerList({
                    userName:userInfor.accountName,
                    deviceId:appKeyObj.deviceId,
                    orgId:single_Orgid,
                    status:4,
                    queryType:1,
                    pageIndex:0,
                    pageSize:6
                },(result,total)=>{
                    if(result && result.length>0){
                      var flag = false;
                      if (result.length > 1){flag = true;}
                      for(var i=0; i<result.length;i++){
                        var html = `
                        <div class="swiper-slide every-hidden-list">
                            <div class="every-slide-type hidden-right-type-`+result[i].status+`">`+self.transStaus(result[i].status)+`</div>
                            <img src="`+picNo(result[i].picUrls.split(',')[0])+`" />
                            <div class="every-slide-flag every-hidden-list-flag" id="swiper_`+result[i].id+`" data-type="`+result[i].status+`">
                              <p style="padding-left: 8px;">`+ moment(result[i].createTime).format("M月D日 HH:mm")+`</p>
                              <p>【`+result[i].createAccountName+`】`+result[i].hiddenDangerDesc+`</p>
                            </div>
                        </div>`;
                        $("#hiddenCheck_swiper").append(html);
                      }
                      if (flag) {
                          var hiddenCheck_swiper = new Swiper('#hiddenCheck-swiper', {
                                direction: 'horizontal',
                                loop: true,
                                autoplay: 5000,
                                slidesPerView: "auto",
                                centeredSlides: true,
                                spaceBetween: 10,
                                pagination: {
                                    el: '#hiddenCheck_pagination',
                                },
                           });
                      }
                      $(".every-hidden-list-flag").click(function(event) {
                          var listId = jQuery(event.currentTarget).attr("id").split("_")[1];
                          var hidden_status= jQuery(event.currentTarget).attr("data-type");
                          if(hidden_status==1){
                            indexFlag=1;
                            app.router.navigate("/goRectification/"+listId+"/");
                          }else if (hidden_status==2) {
                            app.router.navigate("/finishMsg/"+listId+"/");
                          }else if (hidden_status==5) {
                            app.router.navigate("/goAppoint/"+listId+"/");
                          }else {
                            indexFlag=1;
                            app.router.navigate("/goVerify/"+listId+"/");
                          } 
                      });
                    } else {
                      $("#hiddenCheck_swiper").append(`<div class="no-data-img"><img src="`+listNoDataPic()+`"/></div>`);
                      $("#hiddenCheck_pagination").hide();
                      $("#hiddenCheck-bottom").hide();
                      $("#right-con").hide();
                    }
                    $("#stayCahngeNum").html(total);
                },false);                 
            },
            getHiddenAvgDoTimeStatisticsInfo:function(){
                var self = this;
                var $ = self.$$;
                $("#hit_num_text").removeClass('one two three');
                Dao.getHiddenAvgDoTimeStatistics({
                  userName: userInfor.accountName,
                  orgIds:single_Orgid
                },function(data){
                  if(JSON.stringify(data) == "{}"){
                    $("#hidden_delDate").hide();
                    $("#hidden_noDelDate").show();
                  }else{
                    $("#hidden_delDate").show();
                    $("#hidden_noDelDate").hide();
                    data.exceedOrg = data.exceedOrg?new Number(data.exceedOrg).toFixed(1):0;
                    var avgDoTime = data.avgDoTime?new Number(data.avgDoTime).toFixed(1):0;
                    if("0.0" === avgDoTime){
                      avgDoTime = 0 ;
                    }
                    $("#hidden_speed").html(avgDoTime?avgDoTime:0);
                    //处理速度为0时
                    if("0" === $("#hidden_speed").html().toString()){
                      $("#hit_num_text").hide();
                      $("#hidden_delDate").html("最近3个月没有整改隐患！");
                      $("#hit_div").html("及时发现并整改隐患会给单位带来安全的环境。");
                      $("#hit_div").css("font-size","12px");
                    }
                    $("#hit_num").html((data.exceedOrg?data.exceedOrg:0)+"%");
                    if(data.exceedOrg>=80){
                      $("#hit_num_text").html("请继续保持").addClass("one");
                    }else if(data.exceedOrg>=50 && data.exceedOrg<80){
                      $("#hit_num_text").html("要加油啦").addClass("two");
                    }else{
                      $("#hit_num_text").html("请立即整改").addClass("three");
                    }
                  }     
                });
            }
        },
        on: {
            pageInit: function(e, page) {
                  
            },
            pageAfterIn: function(e, page) {
                var self = this;  
                self.getHiddenSwaper();
                self.getHiddenAvgDoTimeStatisticsInfo();  
            }
        }
    }
</script>
